<template>
	<view>
		<view>
			<headerView ref="headerView"></headerView>
			<adView ref="adView"></adView>
			<view class="main">
				<view class="content">
					<view class="title">

						<text class="title1">首页> </text><text class="title1">产品信息> </text><text
							class="title1">产品详情></text>
					</view>
					<view class="content_info">
						<contentRight ref="contentRight"></contentRight>
						
						<view class="cpInfo">
							<text class="textBig">用户信息</text>
							<view class="lianxi">
								<text class="textsmall">用户名字: &nbsp{{cpData.USER}}</text>
								<text class="textsmall">用户类型: &nbsp注册用户</text>
								</view>
							
							<text class="textBig">产品推广信息</text>
							<view class="lianxi">
								<text class="textsmall">查看次数:&nbsp {{cpData.chakan}}次</text>
							<text class="textsmall">app名字:&nbsp {{cpData.CHANPIN_APPMINGZI}}</text>
							<text class="textsmall">推广单价:&nbsp {{cpData.CHANPIN_APPJIAGE}}元</text>
							<text class="textsmall">操作系统:&nbsp {{getxt(cpData)}}</text>
							<text class="textsmall">结算方式: &nbsp{{getjsfs(cpData)}}</text>
							<text class="textsmall">数据查看: &nbsp{{getckKind(cpData)}}</text>
							<text class="textsmall">所属类型:&nbsp {{getLx(cpData)}}</text>
							<text class="textsmall">推广需求: &nbsp{{cpData.CHANPIN_BZ}}</text>
							<text class="textsmall">发布时间:&nbsp{{cpData.CHANPIN_FBSJ}}</text>
							</view>
							<text class="textBig">联系方式</text>
							<view class="lianxi" v-show="isShowLx">
								<view class="qq"><text class="textBig">qq号码:&nbsp {{cpData.CHANPIN_QQHM}}</text>
								<button class="addUserBtn" @click="addUser()">加好友</button>
								</view>
								
								<text class="textBig">微信号码:&nbsp {{cpData.CHANPIN_WXHM}}</text>
								<text class="textBig">手机号码: &nbsp{{cpData.CHANPIN_SJHM}}</text>
							</view>
							<view class="lianxi" v-show="isShowNt">
								<button class="btn2" @click="khy()">会员才能查看联系方式，立即开通</button>
							</view>

							<view style="height: 100px;"></view>
						</view>
						
						

					</view>
				</view>
			</view>
			<footerView ref="footerView"></footerView>
		</view>
	</view>
</template>

<script>
	import headerView from '../header/Headerview.vue'
	import footerView from '../footer/Footer.vue'
	import adView from '../ads/MyAdView.vue'
	import contentRight from '../mainContent/mainContent_right.vue'
	export default {
		components: {
			headerView,
			footerView,
			adView,
			contentRight,
		},

		onShow() {
			
			const eventChannel = this.getOpenerEventChannel();
			eventChannel.on('setCp', (data) => {
				this.cpData = data;
			})
            
			var tj=this.cpData.istj;
			//推荐的帖子 直接显示联系方式，所有人可见
			if(tj!=0){
				this.isShowLx = true;
				this.isShowNt = false;
				return;
			}
			
			if (this.$PublicData.getUserdata() == null || this.$PublicData.getUserdata().userName == null) {
				this.isShowLx = false;
				this.isShowNt = true;
			} else {
				var cpUserid = this.cpData.CHANPIN_APPUSERID;
				var ishy = this.$PublicData.getUserdata().ishy;
				var userId = this.$PublicData.getUserdata().uid;
				//自己发布的帖子可以查看联系方式
				if (cpUserid == userId) {
					this.isShowLx = true;
					this.isShowNt = false;
				} else {
					var ishy = this.$PublicData.getUserdata().ishy;
					if (ishy == 1) { //会员可以看
						this.isShowLx = true;
						this.isShowNt = false;
					} 
					else {
						this.isShowLx = false;
						this.isShowNt = true;
					}
				}

			}

		},


		mounted() {
			uni.$on(this.type, (res) => {
				uni.navigateTo({
					url: './addChangPing',
				})
				
			})
			this.$refs.contentRight.showbtnText("发布产品信息",this.type);
			this.$refs.adView.showMidAd();
			this.$refs.adView.hidSearch();
			this.$refs.adView.hidImageAd();
			this.$refs.contentRight.hidNewCpInfo();
			this.$refs.headerView.setIndex(1);

		},

		data() {
			return {
				cpData: "",
				isShowLx: false,
				isShowNt: true,
				type:"cpDetail",
			}
		},
		methods: {
			getxt(data) {
				return this.$Utils.getXt(data.CHANPIN_CZXT);

			},
			getjsfs(data) {
				return this.$Utils.getJsfs(data.CHANPIN_JSFS);
			},
			getckKind(data){
				return this.$Utils.getckKind(data.CHANPIN_SJCK);
			},
			getLx(data){
				return this.$Utils.getLx(data.CHANPIN_SSLX);
			},
			getContent(data) {
				return "平台:" + this.$Utils.getXt(data.CHANPIN_CZXT) + " 单价:" + data.CHANPIN_APPJIAGE + "元" + " 结算方式:" +
					this.$Utils.getJsfs(data.CHANPIN_JSFS);
			},
			getTime(data) {
				return this.$Utils.getTimer(data);
			},
			addCp() {
				if (this.$PublicData.getUserdata() == null || this.$PublicData.getUserdata().userName == null) {
					this.$Utils.showToast("您还没有登录，请先登录!");
				} else {
					uni.navigateTo({
						url: '../chanping/addChangPing'
					})
				}

			},
			addUser(){
				var qq=this.cpData.CHANPIN_QQHM
				if(qq==null || qq==""){
					return;
				}
				window.location.href = "tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin="+qq
			},
			khy(){
				uni.navigateTo({
					url: '../pay/pay'
				})
	
			},
		}
	}
</script>

<style>
	.title {
		display: flex;
		align-items: center;
	}

	.title1 {
		font-size: 14px;
		color: #000000;
		padding-right: 10px;
		height: 30px;
		display: flex;
		padding-left: 5px;
		align-items: center;
	}

	.main {
		
		display: flex;
		flex-direction: row;
		justify-content: center;
	}

	.content {
		display: flex;
		flex-direction: column;
		width: 1200px;
		height: 100%;
		border: 1px solid #E5E5E5;
	}

	.userInfo {
		padding-top: 20px;
		display: flex;
		flex-direction: column;
		border: 1px solid #E5E5E5;
		width: 100%;
		height: 140px;
		

	}

	.imageTx {
		display: flex;
		align-items: center;
		align-content: center;
		justify-content: center;
	}

	.btn {
		letter-spacing: 0.2rem;
		margin-top: 0.8125rem;
		font-size: 1rem;
		width: 11.875rem;
		border: 0.0625rem solid #F99B15;
		border-radius: 0.3125rem;
		text-align: center;
		justify-content: center;
		align-items: center;
		display: flex;
		height: 2.5rem;
		background: #F99B15;
		color: #FFFFFF;
	}

	.btn2 {
		letter-spacing: 0.2rem;
		margin-top: 0.8125rem;
		font-size: 1rem;
		width: auto;
		border: 0.0625rem solid #F99B15;
		border-radius: 0.3125rem;
		text-align: center;
		justify-content: center;
		align-items: center;
		display: flex;
		height: 2.5rem;
		background: #F99B15;
		color: #FFFFFF;
	}

	.content_info {
		display: flex;
		flex-direction: row;
	}

	.cpInfo {
		padding-right: 50px;
		border: 0.0625rem solid #E5E5E5;
		padding-left: 50px;
		width: 100%;
		display: flex;
		flex-direction: column;
		margin: 5px;

	}

	.textBig {
		display: flex;
		min-height: 30px;
		align-items: center;
		font-size: 16px;
		color: #000000;
		font-weight: bold;
	}

	.textsmall {
		display: flex;
		min-height: 35px;
		align-items: center;
		margin-top: 5px;
		font-size: 15px;
		color: #000000;

	}

	.lianxi {
		padding: 20px;
		background: #F1EFEE;
	}
	.item3 {
		margin-top: 0.8125rem;
		align-items: center;
		padding: 0.3125rem;
		word-wrap: break-word;
		overflow: hidden;
		word-break: break-all;
		flex-direction: column;
		display: flex;
		min-height: 6.875rem;
		border: 0.0625rem solid #E5E5E5;
		border-radius: 0.1875rem;
	}
	.qq{
		display: flex;
		flex-direction: row;
	}
	.addUserBtn{
		height: 30px;
		width: auto;
		display: flex;
		align-items: center;
		justify-content: center;
		
		border: 0.0625rem solid #F99B15;
		border-radius: 0.3125rem;
		background: #F99B15;
		color: #FFFFFF;
	}
	
</style>
